package com.theeviljames.coursework.server;

import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;



public class RadioServer{


	public RadioServer(int delay, int period){
		try {
			ExecutorService pool = Executors.newCachedThreadPool();
			ServerSocket server = new ServerSocket(7778);
			while(true){
				Socket client = server.accept();
				pool.execute(new RadioServerTask(client, delay, period));
				Thread.yield();
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		RadioServer server = new RadioServer(5000, 1000);
	}

}
